package com.jetgege.smartbox.AddBox;

import android.bluetooth.BluetoothDevice;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jetgege.smartbox.R;

import java.util.List;

/**
 * Created by jetgege on 2017/3/12.
 */

public class ScanAdapter extends BaseAdapter{

    //List<BlueModel> mBlueModels;
    List<BluetoothDevice> mBlueModels ;
    public ScanAdapter(List<BluetoothDevice> mBlueModels)
    {
        this.mBlueModels=mBlueModels;
    }

    @Override
    public int getCount() {

        if (mBlueModels.size()<=0) return 0;
        else return mBlueModels.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view=null;
        if (view==null) view=  LayoutInflater.from(parent.getContext()).inflate(R.layout.adddevice_scan_item_list,parent,false);

        TextView tv_BlueName=(TextView) view.findViewById(R.id.tv_BlueName);
        TextView tv_BlueId=(TextView) view.findViewById(R.id.tv_BlueId);

        tv_BlueName.setText(mBlueModels.get(position).getName());
        tv_BlueId.setText(mBlueModels.get(position).getAddress());

        return view;
    }
}
